package org.backend.repository;

import org.backend.pojo.entity.Transaction;
import org.backend.pojo.entity.TransactionItem;
import org.backend.mapper.TransactionMapper;
import org.backend.pojo.vo.CategoryStatisticsVO;
import org.backend.pojo.vo.MonthStatisticsVO;
import org.backend.pojo.vo.ProductWithQuantityVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class TransactionRepository {

    @Autowired
    private TransactionMapper transactionMapper;

    public int insertTransaction(Transaction transaction) {
        return transactionMapper.insertTransaction(transaction);
    }

    public int insertTransactionItems(List<TransactionItem> transactionItems) {
        return transactionMapper.insertTransactionItems(transactionItems);
    }

    public List<Transaction> getTransactionById(Transaction transaction) {
        return transactionMapper.getTransactionById(transaction);
    }

    public Transaction getTransactionByTransactionId(Integer transactionId) {
        return transactionMapper.getTransactionByTransactionId(transactionId);
    }

    public List<ProductWithQuantityVO> getTransactionWithProducts(Integer transactionId) {
        return transactionMapper.getTransactionWithProducts(transactionId);
    }

    public List<Transaction> getAllTransaction() {
        return transactionMapper.getAllTransaction();
    }

    public int deleteTransaction(Integer transactionId) {
        return transactionMapper.deleteTransaction(transactionId);
    }

    public int update(Transaction transaction1) {
        return transactionMapper.update(transaction1);
    }

    public Boolean reviseTransactionStatus(Integer transactionId){
        return transactionMapper.reviseTransactionStatus(transactionId);
    }

    public List<Integer> getTransactionId() {
        return transactionMapper.getTransactionId();
    }

    public List<MonthStatisticsVO> chart(String openid, int year, int month) {
        return transactionMapper.getTransactionByIdForStatistics(openid, year, month);
    }

    public List<CategoryStatisticsVO> categoryChart(String openid) {
        return transactionMapper.categoryChart(openid);
    }
}
